﻿<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <title>LoadData</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="图形系统开发实战:进阶篇 示例">
    <meta name="author" content="hjq">
    <meta name="keywords" content="canvas,anygraph,javascript">
    <!-- frame所需脚本和样式 -->
    <link rel="stylesheet" href="../../script/bootstrap-3.3.5/css/bootstrap.min.css">   
    <link rel="stylesheet" href="../../script/codemirror/codemirror.css">
    <script src="../../script/lib/jquery-1.11.2.min.js"></script>
    <script src="../../script/codemirror/codemirror_merge.js"></script>
    <!-- 加载代码块 -->
	<link rel="stylesheet" href="../css/styles.css">
    <script src="../js/helper.js"></script>
    <script>
        var pageTitle = "加载数组数据";
        var pageDesc = "加载数组数据";
    </script>

    <script type="module">
    import { Graph, Layer, VectorSource, BgUtil } from "../../src/index.js";

    // 初始化graph对象
    let graph = new Graph({
        "target": "graphWrapper"
    });

    // 显示辅助网格
    BgUtil.generateGrid(Object.assign({ "interval": 10, "graph": graph }, graph.getSize()));

    // 增加数据层
    let layer = graph.addLayer({"name":"数据层"});
    layer.getSource().loadData([
        { "type": "Polygon", "coords": [[1, 1], [161, 1], [81, 81]], "style": { "fillStyle": 1, "fillColor": "#caff67" } },
        { "type": "Polygon", "coords": [[1, 2], [81, 82], [1, 162]], "style": { "fillStyle": 1, "fillColor": "#67becf" } },
        { "type": "Polygon", "coords": [[162, 1], [162, 81], [122, 121], [122, 41]], "style": { "fillStyle": 1, "fillColor": "#ef3d61" } },
        { "type": "Polygon", "coords": [[121, 42], [121, 122], [81, 82]], "style": { "fillStyle": 1, "fillColor": "#f9f51a" } },
        { "type": "Polygon", "coords": [[82, 82], [122, 122], [82, 162], [42, 122]], "style": { "fillStyle": 1, "fillColor": "#a54c09" } },
        { "type": "Polygon", "coords": [[42, 122], [82, 162], [2, 162]], "style": { "fillStyle": 1, "fillColor": "#fa8ccc" } },
        { "type": "Polygon", "coords": [[162, 82], [162, 162], [82, 162]], "style": { "fillStyle": 1, "fillColor": "#f6ca29" } }
    ]);

    // 图形渲染
    graph.render();
</script>
</head>

<body style="margin:10px;">
    <div id="graphWrapper" data-type="graph" style="width:100%; height:400px; border:solid 1px #CCC;"></div>
</body>
</html>